﻿using MediatR;
using S.EarTag.API.Application.MediatorCommand.BodyMeasureCommand;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;

namespace S.EarTag.API.Application.MediatorCommandHandler.BodyMeasureCommandHandler
{
    public class BodyMeasureCreateCommandHandler : IRequestHandler<BodyMeasureCreateCommand, bool>
    {
        private readonly IBodyMeasureModelRepository _bodyMeasureModelRepository;
        public BodyMeasureCreateCommandHandler(IBodyMeasureModelRepository bodyMeasureModelRepository)
        {
            _bodyMeasureModelRepository= bodyMeasureModelRepository;
        }
        /// <summary>
        /// 添加体尺测量数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<bool> Handle(BodyMeasureCreateCommand request, CancellationToken cancellationToken)
        {
            return await _bodyMeasureModelRepository.AddAsync(new BodyMeasureModel
            {
                MeasureDate= request.MeasureDate,
                EarTag = request.EarTag,
                Height= request.Height,
                BodyLength= request.BodyLength,
                Chest= request.Chest,
                Tube= request.Tube,
                Oschea= request.Oschea,
                Backfat= request.Backfat,
                EyeMuscleArea= request.EyeMuscleArea,
                EyeMuscleWidth= request.EyeMuscleWidth,
                CreateBy= request.CreateBy,
                CreateDate= request.CreateDate,
                UpdateBy= request.UpdateBy,
                UpdateDate= request.UpdateDate,
            });
        }
    }
}
